package com.xhwl.data.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.FileUploadRecord;
import com.xhwl.common.utils.StringUtils;
import com.xhwl.data.dao.IFileUploadRecordDao;
import com.xhwl.data.service.IFileUploadRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


/**
 * @Author: luyi
 * @Description:
 * @Date: Create in 上午10:29 2022/7/23
 */
@Service
public class FileUploadRecordServiceImpl extends ServiceImpl<IFileUploadRecordDao, FileUploadRecord> implements IFileUploadRecordService {

    private static final Logger log = LoggerFactory.getLogger(FileUploadRecordServiceImpl.class);

    @Override
    public ResultJson setStatus(String url, Short status) {
        if(StringUtils.isEmpty(url)){
            log.warn("更新的地址为空");
            return ResultJson.success();
        }
        QueryWrapper<FileUploadRecord> fileUploadRecordQueryWrapper = new QueryWrapper<>();
        fileUploadRecordQueryWrapper.eq("url", url);
        FileUploadRecord one = this.getOne(fileUploadRecordQueryWrapper);
        if(null == one){
            log.warn("对象不存在 {}", url);
            return ResultJson.success();
        }
        one.setStatus(status);
        updateById(one);
        return ResultJson.success();
    }
}
